<!DOCTYPE html>
<html lang="en">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/resource/common/layui/css/layui.css">
    <link rel="stylesheet" href="/resource/js/front/index.css">
</head>
<style>
    .house-userPer .user-person ul li {
        width: 214px
    }

    .editInfo {
        width: 100%;
        height: 110px;
        color: #84a3bf;
        border: none;
        border-radius: 0;
        border-right: 1px solid #e6e6e6;
        border-left: 1px solid #e6e6e6;
        border-bottom: 1px solid #e6e6e6;
    }
</style>
<body>
<div th:replace="front/head :: heads"></div>
<div class="layui-container userpublic house-userPer">
    <div class="layui-row layui-col-space20">
        <p class="layui-hide-xs title">首页 &gt; <span> </span></p>
        <div th:replace="front/head :: info-nav"></div>
        <div class="layui-col-sm10">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>登录密码</legend>
                <div class="layui-field-box">
                    <div class="layui-form layui-row changePwd">
                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">用户名</label>
                                <div class="layui-input-block">
                                    <input th:value="${userInfo.userName}" name="userName" type="text" value=""
                                           disabled=""
                                           class="layui-input layui-disabled"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">旧密码</label>
                                <div class="layui-input-block">
                                    <input id="oldPwd" name="oldPas" type="password" value="" placeholder="请输入旧密码"
                                           lay-verify="required"
                                           class="layui-input pwd"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">新密码</label>
                                <div class="layui-input-block">
                                    <input id="newPwd" type="password" value="" placeholder="请输入新密码"
                                           lay-verify="required"
                                           name="newPas" class="layui-input pwd"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">确认密码</label>
                                <div class="layui-input-block">
                                    <input type="password" id="confirmPwd" value="" placeholder="请确认密码"
                                           lay-verify="required"
                                           class="layui-input pwd"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit="" lay-filter="changePwd"
                                            style="background-color: #3e94ed">立即修改
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </fieldset>
            <fieldset class="layui-elem-field layui-field-title">
                <legend>支付密码</legend>
                <div class="layui-field-box">
                    <div class="layui-form layui-row changePayPass">
                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">旧密码</label>
                                <div class="layui-input-block">
                                    <input id="oldPayPass" name="oldPayPass" type="password" value=""
                                           placeholder="如未设置过密码则默认密码为(123)"
                                           lay-verify="required"
                                           class="layui-input pwd"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">新密码</label>
                                <div class="layui-input-block">
                                    <input id="newPayPass" type="password" value="" placeholder="请输入新密码"
                                           lay-verify="required"
                                           name="newPayPass" class="layui-input pwd"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">确认密码</label>
                                <div class="layui-input-block">
                                    <input hidden="" name="userName" th:value="${userInfo.userName}">
                                    <input type="password" id="confirmPayPass" value="" placeholder="请确认密码"
                                           lay-verify="required"
                                           class="layui-input pwd"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit="" lay-filter="changePayPass"
                                            style="background-color: #3e94ed">立即修改
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </fieldset>

        </div>
    </div>
</div>
<!-- layui.js -->
<script type="text/javascript" src="/resource/common/layui/layui.js"></script>
<script type="text/javascript" src="/resource/js/front/house.js"></script>
<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
    layui.use(['table', 'layer', 'laydate', 'form'], function () {
        var table = layui.table,
            $ = layui.$,
            layer = layui.layer,
            form = layui.form
        form.on('submit(changePwd)', function (data) {
            if ($("#confirmPwd").val() != $("#newPwd").val()) {
                layer.msg("两次密码输入不一致!");
                return false;
            }
            $.ajax({
                url: '/updatePas',
                type: 'post',
                data: data.field,
                dataType: 'json',
                async: false,
                success: function (result) {
                    if (result.status) {
                        $("#oldPwd").val("");
                        $("#newPwd").val("");
                        $("#confirmPwd").val("");
                        layer.msg("设置成功!");
                    } else {
                        layer.msg(result.msg);
                    }
                    form.render();
                }

            });
        });
        form.on('submit(changePayPass)', function (data) {
            if ($("#confirmPayPass").val() != $("#newPayPass").val()) {
                layer.msg("两次密码输入不一致!");
                return false;
            }
            $.ajax({
                url: '/updatePayPass',
                type: 'post',
                data: data.field,
                dataType: 'json',
                async: false,
                success: function (result) {
                    if (result.status) {
                        $("#oldPayPass").val("");
                        $("#newPayPass").val("");
                        $("#confirmPayPass").val("");
                        layer.msg("设置成功!");
                    } else {
                        layer.msg(result.msg);
                    }
                    form.render();
                }

            });
        });
    });
</script>

</body>
</html>